{% extends "app/layout.html" %}


 {% block content %}
    {% load staticfiles %}
<script charset="utf-8" src="{% static 'kindeditor/kindeditor-all.js' %}"></script>
<script charset="utf-8" src="{% static 'kindeditor/lang/zh-CN.js' %}"></script>

<script charset="utf-8" src="{% static 'kindeditor/plugins/code/prettify.js' %}"></script>
<link id="link" href="{% static '/kindeditor/plugins/code/prettify.css' %}" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
      //KindEditor脚本
      var editor;
      var options={
        width: '760px',
        height: '800px',
        allowFlashUpload:false,
          allowMediaUpload:false,
        resizeType: 1,

        uploadJson: "/upload/", //指定图片上传的url路径，server端写一个视图来处理上传的图片
        extraFileUploadParams: {  "csrfmiddlewaretoken": "{{ csrf_token }}"
        },
        afterUpload:function (url, data, name) {
             if(name=="image" || name=="multiimage"){ //单个和批量上传图片时
                var img = new Image();
                img.src = url;
                img.onload = function(){ //图片必须加载完成才能获取尺寸
                    if(img.width>400) {
                        editor.html(editor.html().replace('<img src="' + url + '"', '<img src="' + url + '" width="400"'))
                    }
                }
            }
        },
        cssPath:"{% static '/kindeditor/plugins/code/prettify.css' %}",
		        allowPreviewEmoticons: false,
		        allowImageUpload: true,
		        items:[
        'undo', 'redo', '|',
		'selectall','cut', 'copy', 'paste','plainpaste', 'wordpaste', '|',
		'justifyleft', 'justifycenter', 'justifyright', 'justifyfull','|',
		'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
        'superscript', '|',
		'clearhtml', 'quickformat', 'removeformat', '|', 'source','preview','fullscreen', '/',
        'formatblock', 'fontname', 'fontsize', '|',
		'forecolor', 'hilitecolor', 'bold','italic', 'underline', 'strikethrough', 'lineheight',  '|',
		'code','image','table', 'hr', 'emoticons', 'baidumap', 'pagebreak', 'anchor', 'link', 'unlink'
				]


      };
      KindEditor.ready(function(K) {

        editor = K.create('#content',options);
		prettyPrint();


      });
</script>

<script>prettyPrint();</script>

    <div class="span8 main-listing">

            <form action="" method="post" class="form-horizontal" name="publishask">
                <input type="hidden" name="id" value="{{form.id}}">
                {% csrf_token %}
    <label>标题</label>
                 <input type="text" name="title" id="title" style="width:750px" maxlength="150" minlength="5" size="80" class="input-common" value="{{form.title}}" >
                <br/>
                <br/>
                <div>
                  <textarea id="content" name="content" style="height:760px;width:760px">{{ form.content }}</textarea>
                </div>
                <br/>
                <br/>
                标签  <input type="text" id="tag" style="width:760px" name="tag" value="{{ form.tag }}">
    <label>最多输入5个标签,请用空格分隔</label>
                <select name="Money_reward" id="Money_reward">
                    <option >1</option>
                    <option >2</option>
                    <option >3</option>
                </select>
                <input type="submit" value="提交"/>

            </form>

    </div>
    <div class="col-md-4">
        <section id="socialLoginForm"></section>
    </div>



{% endblock %}

{% block scripts %}

    {% load staticfiles %}

<script src="{% static 'app/scripts/jquery.validate.min.js' %}"></script>

{% endblock %}
